﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Entity;
using PBOffice.BLL;
using PBOffice.DAL;

public partial  class organ : System.Web.UI.Page
{
    Organ org = new Organ();
    OrganManager organManager = new OrganManager();
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
    /// <summary>
    /// 添加机构信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        GetOrganInfoValue();    //获取机构信息各个属性的值
        bool result = organManager.AddOrganInfo(org);           //添加机构信息到数据库
        if (result == true)
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "OK", "alert('添加成功！')", true);  //添加成功
        else
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "Error", "alert('添加失败！')", true);  //添加失败
    }
    //为机构对象各个属性赋值
    private void GetOrganInfoValue()
    {
        org.OrganId = txtOrganId.Text.Trim();   //机构名称
        org.OrganShortName = txtOrganShortName.Text.Trim();    //机构简称
        org.OrganDirector = txtOrganDirector.Text.Trim();       //负责人
        org.OrganPhone = txtOrganPhone.Text.Trim();             //电话   
        org.OrganMobile = txtOrganMobile.Text.Trim();           //手机
        org.OrganFax = txtOrganFax.Text.Trim();                 //传真
    } 

    /// <summary>
    /// 修改机构信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnChange_Click(object sender, EventArgs e)
    {
        GetOrganInfoValue();    //获取机构信息各个属性的值
        bool result = organManager.ChangeOrganInfo(org);      //修改机构信息
        if (result == true)
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "OK", "alert('修改成功！')", true);  //修改成功
        else
            Page.ClientScript.RegisterClientScriptBlock(typeof(string), "Error", "alert('修改失败！')", true);  //修改失败     
    }
    protected void gvOrgan_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}